document.addEventListener('DOMContentLoaded', function() {
    const checkMobile = () => 
        /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
    
    fetch('https://ip-api.com/json')
        .then(response => response.json())
        .then(data => {
            document.getElementById('ipAddress').textContent = data.query;
            document.getElementById('location').textContent = `${data.city}, ${data.region}`;
        })
        .catch(() => {
            document.getElementById('ipAddress').textContent = '获取失败';
            document.getElementById('location').textContent = '未知';
        });

    document.getElementById('deviceType').textContent = 
        checkMobile() ? '移动设备' : '桌面设备';
});